const db = require('../../db/sql')

function modifyDepartment(params,res){
    const { id,name, parent_id, leader, phone, email } = params;
    const department = {
        name: name,
        parent_id: parent_id,
        leader: leader,
        phone:  phone,
        email:  email
    };

    const sql = 'UPDATE department SET ? where id=?';
    db.query(sql, [department,id], (error, results, fields) => {
        if (error) {
            console.log(err)
            throw error;
        }
        console.log('Department updated:', results.affectedRows);
        res.status(200).send({
            msg:'修改成功'
        })
    });
}
module.exports =modifyDepartment
